package route

import (
	"net/http"

	"gitee.com/liumou_site/disk-monitoring/backend/internal/api"
	"gitee.com/liumou_site/disk-monitoring/backend/pkg"
	"github.com/gin-gonic/gin"
)

// SetupRoutes 设置路由
func SetupRoutes(r *gin.Engine, diskHandler *api.DiskHandler, processHandler *api.ProcessHandler) {
	// 磁盘相关路由
	diskGroup := r.Group("/api/disk")
	{
		diskGroup.GET("/info", diskHandler.GetDiskInfo)
		diskGroup.GET("/io", diskHandler.GetDiskIOStats)
		diskGroup.GET("/io/realtime", diskHandler.GetRealTimeDiskIOData)
	}

	// 进程相关路由
	processGroup := r.Group("/api/process")
	{
		processGroup.GET("/io", processHandler.GetProcessIOStats)
		processGroup.GET("/io/top", processHandler.GetTopProcessIOStats)
		processGroup.GET("/io/realtime", processHandler.GetRealTimeProcessIOData)
	}

	// 健康检查接口
	r.GET("/health", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"status":  "ok",
			"message": "磁盘监控服务运行正常",
			"version": pkg.Version,
			"project": pkg.Project,
			"author":  pkg.Author,
		})
	})
}
